//
//  UnderlyingInvoke.m
//  smarket
//
//  Created by client on 2017/9/25.
//  Copyright © 2017年 原研三品. All rights reserved.
//
#import "UnderlyingInvoke.h"

static NSUInteger indexCount;
static NSString const * staticConstName=@"staticConstName";
const static NSString * constStaticName = @"constStaticName";

@interface UnderlyingInvoke ()

@end

@implementation UnderlyingInvoke

- (instancetype)initWithCoder:(NSCoder *)coder
{
    self = [super init];
    if (self) {
        unsigned int count = 0;
        objc_property_t * propertys = class_copyPropertyList([UnderlyingInvoke class], &count);
        for (int i =0; i < count; i++) {
            objc_property_t property = propertys[i];
            const char * propertyName = property_getName(property);
            NSString * key = [NSString stringWithUTF8String:propertyName];
            id value=  [coder decodeObjectForKey:key];
            [self setValue:value forKey:key];
        }
    }
    return self;
}

-(void)encodeWithCoder:(NSCoder *)aCoder
{
    unsigned int count = 0;
    objc_property_t * propertys = class_copyPropertyList([UnderlyingInvoke class], &count);
    for (int i = 0; i < count; i++) {
        objc_property_t property = propertys[i];
        const char * propertyName = property_getName(property);
        NSString * key = [NSString stringWithUTF8String:propertyName];
        NSString * value = [self valueForKey:key];
        [aCoder encodeObject:value forKey:key];
    }
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        name = @"name";
        indefiner = @"indefiner";
        protect_name = @"protect_name_indefiner";
    }
    return self;
}

+ (void)initialize
{
    if (self == [self class]) {
        underlyingValue = @"underlyingValue";
        staticConstName = @"staticConst";
        constStaticName = @"constStatic";
        if (!someObjects) {
            someObjects = [NSMutableArray arrayWithObjects:@"value1",@"value2",@"value3",nil];
            indexCount = [someObjects count];
        }
    }
}

+(void)read
{
    NSLog(@"underlyingValue =%@ \n",underlyingValue);
    NSLog(@"someObjects=%@",someObjects);
    NSLog(@"indexCount=%zd",indexCount);
}

+(void)write
{
    underlyingValue = @"underlyingValue=> write";
    [someObjects addObject:@"someObjects"];
    indexCount = [someObjects count];
}

+(void)load
{
    
}

@end
